﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 1. Write a JavaScript function reverses string and returns it
			Example: "sample" -> "elpmas". -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		function reverseString(str) {
			var result = "";

			for (var i = str.length - 1; i >= 0 ; i--) {
				result = result.concat(str[i]);
			}

			return result;
		}

		// User input
		var input = prompt("Enter some text");

		// Output
		jsConsole.writeLine("You have entered: " + input);
		jsConsole.writeLine("Reversed string is: " + reverseString(input));
	</script>
</body>
</html>
